package com.moyuwanjia.test;

import com.moyuwanjia.entity.Account02;
import com.moyuwanjia.service.IAccountService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author 摸鱼丸加~
 * @create 2022-04-24 15:31
 *
 *
 */
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig(locations = "classpath:bean_xml.xml")
public class AccountTest_xml {
    @Autowired
    @Qualifier(value = "accountService")
    IAccountService iAccountService;

    /**
     * 未导入spring-test包时的测试方式
     */
    @Test
    public void test01(){
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("bean_xml.xml");
        IAccountService accountService = classPathXmlApplicationContext.getBean("accountService", IAccountService.class);
        log.info("测试log");
        accountService.saveAccount(new Account02(5,"moyu",40000F));
    }

    @Test
    public void test02(){
        iAccountService.transfer("bbb","MoYuWanJia",100F);
    }

}
